package com.shelpe.services.sinbad.entity.mongo;

import java.util.Date;

import org.apache.commons.lang.time.DateFormatUtils;
import org.springframework.data.annotation.Id;
import org.springframework.data.mongodb.core.index.Indexed;
import org.springframework.data.mongodb.core.mapping.Document;

import com.shelpe.services.sinbad.dto.EffectMetricDto;
import com.shelpe.services.sinbad.entity.jpa.User;

import lombok.Data;

@Data
@Document(collection = "cost_rtr")
public class CostRtr {

	@Id
	private String id;

	@Indexed
	private long userID;

	@Indexed
	private Date date;
	
	private int minute;

	private EffectMetricDto metric;

	public void from(User user, Date date,int time) {
		this.userID = user.getUserID();
		this.minute = time;
		this.date = date;
		this.id = DateFormatUtils.format(this.date, "yyyy-MM-dd HH:mm") + "_" + this.userID;
	}
}
